/*
 * @lc app=leetcode.cn id=2006 lang=typescript
 *
 * [2006] 差的绝对值为 K 的数对数目
 */

// @lc code=start
function countKDifference(nums: number[], k: number): number {
    let count = 0;
    for (let i = 0; i < nums.length; i++) {
        const element = nums[i];
        const last = element - k;
        const prev = element + k;
        for (let j = i + 1; j < nums.length; j++) {
            const el1 = nums[j];
            if (el1 === last || el1 === prev) {
                count++;
            }
        }
    }
    return count;
}
// @lc code=end
